//
//  ZHButton.m
//  ZHS_UCDemo
//
//  Created by Emrys on 2016/11/7.
//  Copyright © 2016年 Emrys. All rights reserved.
//

#import "ZHButton.h"

@implementation ZHButton

- (void)setCornerRedius:(CGFloat)cornerRedius {
    _cornerRedius = cornerRedius;
    
    self.layer.cornerRadius = _cornerRedius;
    self.layer.masksToBounds = YES;
}

- (void)setTopLeftRightCornerRedius:(CGFloat)topLeftRightCornerRedius {
    _topLeftRightCornerRedius = topLeftRightCornerRedius;
    
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds
                                                   byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
                                                         cornerRadii:CGSizeMake(topLeftRightCornerRedius, topLeftRightCornerRedius)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = self.bounds;
    maskLayer.path = maskPath.CGPath;
    self.layer.mask = maskLayer;
    
    self.layer.masksToBounds = YES;
    [self clipsToBounds];
}

@end
